Re: Display skip list pommCannelle - Mon Jun 22 06:00:27 EDT 2015
Use a simple text box should be enough ;)
[code]
DB testBox = null
DBE testTextDbe = null
Buffer testBuf = null
Skip testskp = create
put(testskp, 0, "first value") // error here ;)
put(testskp, 1, "first value")
put(testskp, 2, "second value")
// combine to properly deal with memory
void combine ( Buffer b, string s ) {
Buffer tmp = create
tmp = s; combine ( b, tmp, 0 )
delete tmp
}
// build a skip using a string ...
Skip split ( string s, char c ) {
Skip split_string = create();
int deb = 0; int i; int index = 0;
for ( i=0; i<length(s)-1; i++ ) {
if ( s[i] != c ) continue;
put( split_string, index, s[deb:i-1] );
deb = i+1; index += 1;
}
if ( s[i] == c ) i--;
put( split_string, index, s[deb:i] );
return(split_string);
}
void clear_test_(DB d) {
if (null testBuf) return
if (null testTextDbe) return
setempty testBuf
set(testTextDbe,testBuf)
}
void close_test_(DB d) {
if ( !null testBox) { delete(testBuf) }
testBox = null
testTextDbe = null
hide d; destroy d
delete testskp
}
void display_skp_(DB d){
if (null testskp) return
if (null testTextDbe) return
string tmp
if (null testBuf) testBuf = create()
for tmp in testskp do combine(testBuf, tmp "\n")
set(testTextDbe, testBuf)
}
void update_skp_(DB d){
if (null testTextDbe) return
string tmp = get(testTextDbe)
delete testskp; testskp = null
if (tmp"" == "") { infoBox "Skip deleted."; return }
testskp = split(tmp, '\n')
infoBox "Skip updated."
}
testBox = create("Log", styleCentered|styleFloating)
testTextDbe = text(testBox,"", "", 400, 200, false)
testTextDbe->"top"->"form"
testTextDbe->"right"->"form"
testTextDbe->"left"->"form"
testTextDbe->"bottom"->"form"
close(testBox,true,close_test_)
apply(testBox,"Clear",clear_test_)
apply(testBox,"Display skip",display_skp_)
apply(testBox,"Update skip", update_skp_)
show testBox
[\code]
|